package com.gitee.linmt.config;

import org.springframework.security.access.expression.method.ExpressionBasedAnnotationAttributeFactory;
import org.springframework.security.access.method.MethodSecurityMetadataSource;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;

/**
 * 从数据库获取权限限制信息.
 *
 * @author <a href="mailto:lin-mt@outlook.com">lin-mt</a>
 */
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class GlobalMethodSecurityConfigurationFromJdbc extends GlobalMethodSecurityConfiguration {
    
    @Override
    protected MethodSecurityMetadataSource customMethodSecurityMetadataSource() {
        ExpressionBasedAnnotationAttributeFactory attributeFactory = new ExpressionBasedAnnotationAttributeFactory(
                getExpressionHandler());
        return new PrePostJdbcSecurityMetadataSource(attributeFactory);
    }
}
